import http from "@/api";
import { joinQueryParams } from "@/utils/qs";
import { AppointListType } from "./type";

export const uploadFileUrl = import.meta.env.VITE_API_URL + "/reservation/uploadFile";

// 枚举
enum Api {
  // 分页查询预约审核列表
  selectByPage = "/reservation/selectByPage",
  // 添加预约审核
  addReservation = "/reservation/add",
  // 审核
  checkReservation = "/reservation/check",
  // 导出Excel表格
  exportExcel = "/reservation/export"
}

// 查询响应类型
interface selectResType {
  list: AppointListType;
  total: number;
}

// 分页查询预约审核列表的Api
export const selectByPageApi = (data: {
  studentName: string;
  studentCode: string;
  startReservationDate: string;
  endReservationDate: string;
  reservationHome: string;
  reservationDev: string;
  checkResult: string;
  page: string;
  size: string;
}) => {
  return http.post<selectResType>(Api.selectByPage + joinQueryParams(data), {}, { loading: false });
};

// 发起预约的Api
export const addReservationApi = data => {
  return http.post(Api.addReservation + joinQueryParams(data), {}, { loading: false });
};

// 审核预约的Api
export const checkReservationApi = data => {
  return http.post(Api.checkReservation + joinQueryParams(data), {}, { loading: false });
};

// 导出Excel的Api
export const exportExcelApi = data => {
  return http.download(Api.exportExcel + joinQueryParams(data), {}, { loading: false });
};
